Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
This pull request implements the FloatingPoint package by refactoring the DIR‑4‑15 query to be shared with DIR‑0‑3‑1 and updating test cases to reflect improved floating point guard behavior.
- Added cosine and sine declarations in the standard-library header.
- Updated change notes to document modifications in infinity/NaN detection.
- Updated test cases for misuse of NaN and infinite floating point values with revised compliance annotations.
Reviewed Changes
Copilot reviewed 15 out of 31 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| cpp/common/test/includes/standard-library/math.h | Added overloads for cos and sin to support floating point operations. |
| change_notes/2025-04-14-update-infinity-nan-detection.md | Documented the updated behavior for NaN and infinity detection. |
| c/common/test/rules/misuseofnanfloatingpointvalue/test.c | Introduced tests for casting and comparisons involving NaN values. |
| c/common/test/rules/misuseofinfinitefloatingpointvalue/test.c | Updated test cases with revised compliance annotations for infinite and NaN scenarios. |
Files not reviewed (16)
- c/common/test/rules/misuseofinfinitefloatingpointvalue/MisuseOfInfiniteFloatingPointValue.expected: Language not supported
- c/common/test/rules/misuseofinfinitefloatingpointvalue/MisuseOfInfiniteFloatingPointValue.ql: Language not supported
- c/common/test/rules/misuseofnanfloatingpointvalue/MisuseOfNaNFloatingPointValue.expected: Language not supported
- c/common/test/rules/misuseofnanfloatingpointvalue/MisuseOfNaNFloatingPointValue.ql: Language not supported
- c/misra/src/rules/DIR-4-15/PossibleMisuseOfUndetectedInfinity.ql: Language not supported
- c/misra/src/rules/DIR-4-15/PossibleMisuseOfUndetectedNaN.ql: Language not supported
- c/misra/test/rules/DIR-4-15/PossibleMisuseOfUndetectedInfinity.testref: Language not supported
- c/misra/test/rules/DIR-4-15/PossibleMisuseOfUndetectedNaN.testref: Language not supported
- cpp/common/src/codingstandards/cpp/FloatingPoint.qll: Language not supported
- cpp/common/src/codingstandards/cpp/RestrictedRangeAnalysis.qll: Language not supported
- cpp/common/src/codingstandards/cpp/exclusions/cpp/FloatingPoint.qll: Language not supported
- cpp/common/src/codingstandards/cpp/exclusions/cpp/RuleMetadata.qll: Language not supported
- cpp/common/src/codingstandards/cpp/rules/misuseofinfinitefloatingpointvalue/MisuseOfInfiniteFloatingPointValue.qll: Language not supported
- cpp/common/src/codingstandards/cpp/rules/misuseofnanfloatingpointvalue/MisuseOfNaNFloatingPointValue.qll: Language not supported
- cpp/common/test/includes/standard-library/cmath: Language not supported
- cpp/common/test/rules/misuseofinfinitefloatingpointvalue/MisuseOfInfiniteFloatingPointValue.expected: Language not supported
Comments suppressed due to low confidence (6)
c/common/test/rules/misuseofinfinitefloatingpointvalue/test.c:36
- The compliance annotation for casting a NaN value (for (int)l5 and similarly for (int)l6) now indicates COMPLIANT, which differs from the misuseofnanfloatingpointvalue tests. Please verify that this change reflects the intended behavior for infinite value misuse tests.
(int)l5; // COMPLIANT: Casting NaN to int
c/common/test/rules/misuseofinfinitefloatingpointvalue/test.c:201
- The annotation change for castToIntToFloatToInt with a NaN input now marks it as COMPLIANT. Please confirm this accurately reflects the intended behavior in the context of infinite floating point misuse.
castToIntToFloatToInt(0.0 / 0.0); // COMPLIANT
c/common/test/rules/misuseofinfinitefloatingpointvalue/test.c:209
- The expected compliance for casting middleNaN is now COMPLIANT. Please verify that this change aligns with the overall intended query behavior compared to similar tests in misuseofnanfloatingpointvalue.
castToInt(middleNaN); // COMPLIANT
c/common/test/rules/misuseofinfinitefloatingpointvalue/test.c:211
- Marking addNaNThenCastToInt with middleNaN as COMPLIANT now differs from previous non-compliant annotations in related tests. Please ensure this change is intentional and consistent with the intended behavior for infinite misuse scenarios.
addNaNThenCastToInt(middleNaN); // COMPLIANT
c/common/test/rules/misuseofinfinitefloatingpointvalue/test.c:161
- The false negative annotation for (int)pow(2, p1) indicates a possible detection gap for infinity. It would be beneficial to confirm that this behavior is expected within the updated query logic.
(int)pow(2, p1); // NON_COMPLIANT[False negative]: likely to be Infinity
c/common/test/rules/misuseofinfinitefloatingpointvalue/test.c:198
- The false negative label for addOneThenCastToInt with an infinite input suggests a potential oversight in detecting misuse. Please double-check that this annotation is correct and aligns with the overall test expectations.
addOneThenCastToInt(1.0 / 0.0); // NON_COMPLIANT[False negative]
lcartey
approved these changes
Apr 30, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Move
DIR-4-15to be a shared query to supportDIR-0-3-1Change request type
.ql,.qll,.qlsor unit tests)Rules with added or modified queries
DIR-0-3-1DIR-4-15Release change checklist
A change note (development_handbook.md#change-notes) is required for any pull request which modifies:
If you are only adding new rule queries, a change note is not required.
Author: Is a change note required?
🚨🚨🚨
Reviewer: Confirm that format of shared queries (not the .qll file, the
.ql file that imports it) is valid by running them within VS Code.
Reviewer: Confirm that either a change note is not required or the change note is required and has been added.
Query development review checklist
For PRs that add new queries or modify existing queries, the following checklist should be completed by both the author and reviewer:
Author
As a rule of thumb, predicates specific to the query should take no more than 1 minute, and for simple queries be under 10 seconds. If this is not the case, this should be highlighted and agreed in the code review process.
Reviewer
As a rule of thumb, predicates specific to the query should take no more than 1 minute, and for simple queries be under 10 seconds. If this is not the case, this should be highlighted and agreed in the code review process.